package com.yay.rental.ui;

import android.os.Bundle;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.yay.rental.R;


/**
 * Get Started!
 * @author team@getstarted.com.ua
 */
public class RentalMapActivity extends MapActivity {
	private MapView mapView;
	//private List<Overlay> mapOverlays;
	//private RentalItemizedOverlay itemizedOverlay;
	private MapController mc;

	
	@Override
	protected boolean isRouteDisplayed() {
	    return false;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);
        
        initMap();
	}
	
	private void initMap() {
        mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
        //mapOverlays = mapView.getOverlays();
        
        /*Ticket currentTicket = TicketsService.getCurrentTicket();
        GeoPoint point = new GeoPoint((int)(currentTicket.getLatitude()), (int)(currentTicket.getLongitude()));
        
        if(TicketsAdapter.getTickets().size() == 0 || TicketsAdapter.reload) {
        	TicketsAdapter.getTickets().clear();
        	TicketsAdapter.reload = false;
        	int type = currentTicket.getType() == LFType.LOST.getId() ? LFType.FOUND.getId() : LFType.LOST.getId();
        	TicketsAdapter.getTickets().addAll(getTicketsService().find(type, currentTicket.getCategory(), currentTicket.getLatitude(), currentTicket.getLongitude()));
        }
        
        for(final Ticket ticket: TicketsAdapter.getTickets()) {
        	OverlayItem overlayitem = new OverlayItem(point, "", "");
        	drawable = this.getResources().getDrawable(Category.findById(ticket.getCategory()).getDrawable());
        	itemizedOverlay = new LostItemizedOverlay(drawable) {
        		@Override
        		protected boolean onTap(int index) {
        			getContact().putExtra(IKeys.TICKET, ticket);
            		startActivity(getContact());
        			return true;
        		}
        	};
        	itemizedOverlay.addOverlay(overlayitem);
        	mapOverlays.add(itemizedOverlay);
        }*/
        
        mc = mapView.getController();
        //mc.animateTo(point);
        mc.setZoom(17); 
        mapView.invalidate();
	}
		
}
